# -*- encoding: utf-8 -*-

from google.appengine.api import users

from django import template

register = template.Library()

class IfAdminNode(template.Node):
    def __init__(self, nodelist):
        self.nodelist = nodelist

    def render(self, context):
        if users.is_current_user_admin():
            return self.nodelist.render(context)
        else:
            return ''
    

@register.tag(name="ifadmin")
def do_ifadmin(parser, token):
    nodelist = parser.parse(('endifadmin',))
    parser.delete_first_token()
    return IfAdminNode(nodelist)
